package ace.module.sms.supplier.api.sms4j.autoconfig;

import ace.module.sms.supplier.api.sms4j.core.Sms4jProviderBoostrapScanner;
import jakarta.annotation.PostConstruct;
import org.dromara.sms4j.api.dao.SmsDao;
import org.dromara.sms4j.api.dao.SmsDaoDefaultImpl;
import org.dromara.sms4j.provider.config.SmsConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author caspar
 * @date 2023/2/6 20:09 自动配置 验证码module
 */
@ComponentScan(basePackageClasses = Sms4jProviderBoostrapScanner.class)
@Configuration
public class Sms4jProviderAutoConfig {

  @Autowired private SmsConfig smsConfig;

  @PostConstruct
  public void construct() {
    smsConfig.setIsPrint(false);
  }

  @Bean
  @ConditionalOnMissingBean
  public SmsDao smsDao() {
    return SmsDaoDefaultImpl.getInstance();
  }
}
